package com.moneytree.service.impl;

import java.util.List;

import com.moneytree.model.Loan;
import com.moneytree.service.LoanService;
import com.moneytree.utils.Page;
import com.moneytree.utils.PersistenceUtils;

public class LoanServiceImpl extends PersistenceUtils<Loan, String> implements LoanService {

	@Override
	public Loan queryById(String id) {
		return get(id);
	}

	@Override
	public void save(Loan loan) {
		super.save(loan);
	}
	
	@Override
	public void saveOrUpdate(Loan loan) {
		super.saveOrUpdate(loan);
	}

	@Override
	public void delete(Loan loan) {
		// TODO Auto-generated method stub
	}

	@Override
	public Loan queryLoan(Loan loan) {
		return query(loan);
	}

	@Override
	public Page queryBean(Loan loan, Page page) {
		int start = Page.countOffset(page.getPageSize(), page.getCurrentPage());
		int allCount = super.count(loan);
		List<Loan> list = super.queryList(loan, start, page.getPageSize());
		return Page.toPage(list, page.getCurrentPage(), page.getPageSize(), allCount);
	}

}
